package com.ssy.lingxi.order.model.bo;

import com.ssy.lingxi.order.entity.OrderDO;
import com.ssy.lingxi.order.entity.OrderProductDO;
import com.ssy.lingxi.order.model.dto.SupplyProductDTO;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 订单Id、商城Id及供应会员、供应会员商品列表
 * @author 万宁
 * @version 2.0.0
 * @date 2021-09-13
 */
public class OrderShopProductBO implements Serializable {
    private static final long serialVersionUID = 1310398622302677983L;

    public OrderShopProductBO() {
    }

    public OrderShopProductBO(OrderDO order, List<OrderProductDO> products, List<SupplyProductDTO> supplyProducts) {
        this.orderId = order.getId();
        this.shopId = order.getShopId();
        this.vendorMemberId = order.getSupplyMemberId();
        this.vendorRoleId = order.getSupplyRoleId();
        this.products = supplyProducts.stream().filter(supplyProduct -> products.stream().anyMatch(product -> product.getSkuId().equals(supplyProduct.getVendorSkuId()))).map(supplyProduct -> new OrderProductBO(supplyProduct.getProductId(), supplyProduct.getSkuId())).collect(Collectors.toList());
    }

    public OrderShopProductBO(Long orderId, Long shopId, Long vendorMemberId, Long vendorRoleId, List<OrderProductBO> products) {
        this.orderId = orderId;
        this.shopId = shopId;
        this.vendorMemberId = vendorMemberId;
        this.vendorRoleId = vendorRoleId;
        this.products = products;
    }

    /**
     * 订单Id
     */
    private Long orderId;

    /**
     * 商城Id
     */
    private Long shopId;

    /**
     * 供应会员Id
     */
    private Long vendorMemberId;

    /**
     * 供应会员角色Id
     */
    private Long vendorRoleId;

    /**
     * 供应会员商品列表
     */
    private List<OrderProductBO> products;

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Long getShopId() {
        return shopId;
    }

    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }

    public Long getVendorMemberId() {
        return vendorMemberId;
    }

    public void setVendorMemberId(Long vendorMemberId) {
        this.vendorMemberId = vendorMemberId;
    }

    public Long getVendorRoleId() {
        return vendorRoleId;
    }

    public void setVendorRoleId(Long vendorRoleId) {
        this.vendorRoleId = vendorRoleId;
    }

    public List<OrderProductBO> getProducts() {
        return products;
    }

    public void setProducts(List<OrderProductBO> products) {
        this.products = products;
    }
}
